<include file='public/_meta'>

<div class="page-container">
    <div class="Huialert Huialert-success"><i class="Hui-iconfont">&#xe6a6;</i>
        <p class="c-primary">
            操作提示
        </p>
        <ul>
          <li>车辆控制</li>

          <li>暂只支持控制赛卡车辆(博鹭途)</li>


        </ul>
    </div>
    <div class="cl pd-5 bg-1 bk-gray mt-20 text-c">
        <span class=""> <a class="btn btn-primary radius" onclick="unlock({$id})" href="javascript:;"><i class="Hui-iconfont">&#xe605;</i> 开锁</a></span>  
        <span class="ml-50"> <a class="btn btn-success radius" onclick="lock({$id})" href="javascript:;"><i class="Hui-iconfont">&#xe60e;</i> 落锁</a></span>
        <span class="ml-50"> <a class="btn btn-warning radius" onclick="ignite({$id})" href="javascript:;"><i class="Hui-iconfont">&#xe6c1;</i> 点火</a></span> 
        <span class="ml-50"> <a class="btn btn-success radius" onclick="unignite({$id})" href="javascript:;"><i class="Hui-iconfont">&#xe6b2;</i> 熄火</a></span> 
        <span class="ml-50"> <a class="btn btn-warning radius" onclick="whistle({$id})" href="javascript:;"><i class="Hui-iconfont">&#xe62f;</i> 鸣笛</a></span> 
    </div>
    
    <if condition="$cars['supplier_no'] == 1376920003">
        <div class="cl pd-5 bg-1 bk-gray mt-20 text-c">
            <span class=""> <a class="btn btn-primary radius" onclick="photographer('{$cars['car_unique_id']}')" href="javascript:;"><i class="Hui-iconfont">&#xe685;</i> 拍照</a></span> 
            <span class="ml-50"> <a class="btn btn-secondary radius" onclick="rentType('{$cars['car_unique_id']}',1)" href="javascript:;"><i class="Hui-iconfont">&#xe69e;</i> 分时用车</a></span>  
            <span class="ml-50"> <a class="btn btn-success radius" onclick="rentType('{$cars['car_unique_id']}',2)" href="javascript:;"><i class="Hui-iconfont">&#xe69e;</i> 长租用车</a></span>
            <span class="ml-50"> <a class="btn btn-danger radius" onclick="rentType('{$cars['car_unique_id']}',9)" href="javascript:;"><i class="Hui-iconfont">&#xe69e;</i> 永久锁定</a></span> 
        </div>
    </if>
    <if condition="$data!=null">
    <div class="page-container mt-5 ml-10 mr-10 f-16">
        <p class="text-c label-primary c-white pd-5">车机数据</p>
        <div class="cl">
            <div class="col-xs-6 col-sm-6">
                <ul>
                    <li>车牌号 {$cars.car_sn}</li>
                    <li>车架号 ：{$cars.car_unique_id}</li>
                    <li>主物联网卡号 ：{$cars.cardcode}</li>
                    <li>主车载设备的编号 ：{$cars.equipment_id}</li>
                    <li>车机版本 : {$data.machine_version}</li>
                    <if condition="$data.long_term_lease!==null">
                        <li>长租类型 : {$data.long_term_lease == 0 ? '分时用车':'长租用车'}</li>
                    </if>
                    <li>总里程 : {$data.mileage}公里</li>
                    <li>剩余里程 : {$data.mileage_surplus}km</li>
                    <if condition="$data.total_voltage!==null">
                        <li>总电压 : {$data.total_voltage}V</li>
                    </if>
                    <li>小瓶电压 : {$data.voltage}V</li>
                    <if condition="$data.total_electricity!==null">
                        <li>总电流 : {$data.total_electricity}A</li>
                    </if>
                    <li>电池电量 : {$data.soc}%</li>
                    <li>速度 : {$data.speed}km/h</li>
                    <li>方向 : {$data.direction}°</li>
                    <if condition="$data.gprs_signal!==-1">
                        <li>GPRS强度 : {$data.gprs_signal>=8?($data.gprs_signal>12?'可GPRS':'GPRS不稳定'):'可发送短信'}</li>
                    </if>
                    <if condition="$data.gps_signal!==-1">
                        <li>卫星个数 : {$data.gps_signal}</li>
                    </if>
                    
                    <li>车机时间 : {:date('Y-m-d H:i:s',$data['time']/1000)}</li>
                </ul>
            </div>
            
            <div class="col-xs-6 col-sm-6">
                <ul>
                    <li>联网状态 : {$data.network_status == 0?'<span class="label radius">离线</span>':'<span class="label label-success radius">在线</span>'}</li>
                    <li>Ready状态 : {$data.ready_status==0?'非':''}Ready</li>
                    <li>点熄火状态 : {$data['launch_status']==1?'点火状态':'熄火状态'}</li>
                    <li>钥匙状态 : {$data.acc_status==0?'OFF':'ON'}</li>
                    <li>档位信息 :  {$data.gear}档</li>
                    <li>运行动力 : {$data.power_model==1?'纯电':'未知'}</li>
                    <if condition="$data.obd_status!==-1">
                        <li>车机插拔状态 : {$data.obd_status==1?'插上':'拔掉'}</li>
                    </if>
                    <present name="data.control_lock">
                        <li>永久锁定状态 : {$data.control_lock==0?'未锁定':'锁定'}</li>
                    </present>

                    <present name="data.mind_cons">
                        <li>中控锁状态 : {$data.mind_cons==0?'未锁':'锁'}</li>
                    </present>

                    <present name="data.alarm">
                        <li>防盗报警状态 : {$data.alarm==0?'正常':'报警'}</li>
                    </present>

                    <present name="data.running_lights">
                        <li>行车灯/示宽灯 : {$data.running_lights==0?'关':'开'}</li>
                    </present>
                    
                    <li>充电状态 : {$data['charge_status']?'充电中':'未充电'}</li>
                    <li>左前门 : {$data.door_lf == 0?'关门':'开门'}</li>
                    <li>右前门 : {$data.door_rf == 0?'关门':'开门'}</li>
                    <li>左后门 : {$data.door_lb == 0?'关门':'开门'}</li>
                    <li>右后门 : {$data.door_rb == 0?'关门':'开门'}</li>
                    <if condition="$data.positioning_validity!==-1">
                        <li>定位数据有效性 : {$data.positioning_validity==1?'有效':'无效'}</li>
                    </if>
                    <li>车辆位置 : {$gaodeapi['regeocode']['formatted_address']?$gaodeapi['regeocode']['formatted_address']:''} <span class="c-primary">(街道编号 : {$gaodeapi['regeocode']['addressComponent']['streetNumber']['street']?$gaodeapi['regeocode']['addressComponent']['streetNumber']['street']:''} {$gaodeapi['regeocode']['addressComponent']['streetNumber']['number']?$gaodeapi['regeocode']['addressComponent']['streetNumber']['number']:''})</span></li> 
                </ul>
            </div>
        </div>
    </div>
</if>
</div>

<!--_footer 作为公共模版分离出去-->
<include file='public/_footer'>
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本--> 
<script type="text/javascript" src="__PUBLIC__/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__PUBLIC__/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="__PUBLIC__/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="__PUBLIC__/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript">
function unlock(id) {
    layer.confirm('确认要开锁吗？',function(index){
        // console.log('ss')
        $.ajax({
            type: 'GET',
            url: "{:url('index/operate/unlock')}",
            data:{'id':id},
            dataType: 'json',
            success: function(data){
                if(data.result == 0){
                    console.log(111)
                
                    layer.msg('指令发送成功!',{icon:1,time:1000});
                }else{
                    layer.msg(data['msg']);
                }
                if(data.code==0){
                    top.location.href = "{:url('index/index/index')}"
                }
            },
            error:function(data) {
                console.log(data.msg);
            },
        });     
    });
    
}
function lock(id) {
    layer.confirm('确认要落锁吗？',function(index){
        // console.log('ss')
        $.ajax({
            type: 'GET',
            url: "{:url('index/operate/lock')}",
            data:{'id':id},
            dataType: 'json',
            success: function(data){
                console.log(data)
                if(data.result == 0){               
                    layer.msg('指令发送成功!',{icon:1,time:1000});
                }else{
                    layer.msg(data['msg']);
                }
                if(data.code==0){
                    top.location.href = "{:url('index/index/index')}"
                }
            },
            error:function(data) {
                console.log(data.msg);
            },
        });     
    });
    
}
function ignite(id) {
    layer.confirm('确认要点火吗？',function(index){
        // console.log('ss')
        $.ajax({
            type: 'GET',
            url: "{:url('index/operate/ignite')}",
            data:{'id':id},
            dataType: 'json',
            success: function(data){
                if(data.result == 0){               
                    layer.msg('指令发送成功!',{icon:1,time:1000});
                }else{
                    layer.msg(data['msg']);
                }
                if(data.code==0){
                    top.location.href = "{:url('index/index/index')}"
                }
            },
            error:function(data) {
                console.log(data.msg);
            },
        });     
    });
    
}
function unignite(id) {
    layer.confirm('确认要熄火吗？',function(index){
        // console.log('ss')
        $.ajax({
            type: 'GET',
            url: "{:url('index/operate/unignite')}",
            data:{'id':id},
            dataType: 'json',
            success: function(data){
                if(data.result == 0){               
                    layer.msg('指令发送成功!',{icon:1,time:1000});
                }else{
                    layer.msg(data['msg']);
                }
                if(data.code==0){
                    top.location.href = "{:url('index/index/index')}"
                }
            },
            error:function(data) {
                console.log(data.msg);
            },
        });     
    });
    
}
function whistle(id) {
    layer.confirm('确认要鸣笛吗？',function(index){
        // console.log('ss')
        $.ajax({
            type: 'GET',
            url: "{:url('index/operate/whistle')}",
            data:{'id':id},
            dataType: 'json',
            success: function(data){
                if(data.result == 0){               
                    layer.msg('指令发送成功!',{icon:1,time:1000});
                }else{
                    layer.msg(data['msg']);
                }
                if(data.code==0){
                    top.location.href = "{:url('index/index/index')}"
                }
            },
            error:function(data) {
                console.log(data.msg);
            },
        });     
    });
    
}

function rentType(car_unique_id,type) {
    layer.confirm('确认要操作吗？',function(index){
        // console.log('ss')
        $.ajax({
            type: 'GET',
            url: "{:url('index/operate/rent_type')}",
            data:{
                'car_unique_id':car_unique_id,
                'type':type
            },
            dataType: 'json',
            success: function(data){
              if(data.result == 0){               
                    layer.msg(data['msg'],{icon:1,time:1000});
                }else{
                    layer.msg(data['msg']);
                }  
            },
            error:function(data) {
                console.log(data.msg);
            },
        });     
    });
    
}

function photographer(car_unique_id){
    layer.confirm('确认要操作吗？',function(index){
        // console.log('ss')
        $.ajax({
            type: 'GET',
            url: "{:url('index/operate/photographer')}",
            data:{
                'car_unique_id':car_unique_id
            },
            dataType: 'json',
            success: function(data){
                if(data.result == 0){               
                    layer.msg(data['msg'],{icon:1,time:1000});
                }else{
                    layer.msg(data['msg']);
                }  
            },
            error:function(data) {
                console.log(data.msg);
            },
        });     
    });
}

</script> 
<!--/请在上方写此页面业务相关的脚本-->